home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Games / Tetris / Source / RCS / NextMatrix.m,v < prev    next >
Encoding:
Text File  |  1975-04-26  |  3.9 KB  |  295 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ;
  6. comment  @@;
  7.  
  8.  
  9. 1.8
  10. date     92.03.01.10.26.49;  author melling;  state Exp;
  11. branches ;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     92.03.01.05.07.31;  author melling;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     92.02.29.20.35.38;  author melling;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     92.02.28.05.18.47;  author melling;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     91.12.19.10.12.33;  author melling;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     91.12.16.17.21.59;  author melling;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     91.12.07.07.48.53;  author melling;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     91.12.07.03.36.47;  author melling;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @Tetris 1.1
  52. @
  53.  
  54.  
  55. 1.8
  56. log
  57. @Release 1.3
  58. @
  59. text
  60. @/*
  61.  *  The View that displays the next piece that will drop.
  62.  *
  63.  */
  64. #import <appkit/Application.h>
  65. #import <appkit/NXImage.h>
  66. #import <appkit/Button.h>
  67. #import "NextMatrix.h"
  68. #import "Piece.h"
  69.  
  70. @@implementation NextMatrix
  71.  
  72. - initFrame:(const NXRect *)frameRect
  73. {
  74.     NXSize size;
  75.      extern resize(NXSize *);
  76.  
  77.     [super initFrame:frameRect numRows:0 numCols:0];
  78.  
  79.     thePiece = [[Piece alloc] init];
  80.     [thePiece newPiece];
  81.  
  82.     [thePiece getBlockSize:&size];
  83.      resize(&size);
  84.     [super setElementSize:&size]; // Remember the image's size.
  85.      pieceVisible = showNext = NO;
  86.     size.width = size.height = 1.0;
  87.     [super setIntercell:&size];
  88.  
  89. #ifdef DEBUG
  90.      fprintf(stderr, "NextMatrix initialized\n");
  91. #endif
  92.     return self;
  93. }
  94.  
  95.  
  96. - drawSelf:(const NXRect *)rects :(int)rectCount
  97. {
  98.     [super drawSelf:rects :rectCount];
  99.      fprintf(stderr, "Thinking about showing you the next piece\n");
  100.     if (pieceVisible && showNext) {
  101.          fprintf(stderr, "Here's the next piece.\n");
  102.          [thePiece draw:self];      // Show the next piece
  103.      }
  104.     return self;
  105. }
  106.  
  107.  
  108. - (struct pieceInfo *)pieceInfo
  109. {
  110.     struct pieceInfo *info;
  111. #ifdef DEBUG
  112.      puts("NextMatrix instance creating a new piece");
  113. #endif
  114.     info = [thePiece pieceInfo];
  115.     [thePiece newPiece];          // Generate the new piece
  116.  
  117.     [self display];
  118.     return info;
  119. }
  120.  
  121. /*
  122.  * TetApp will inform us when the game has started.
  123.  */
  124. - start:sender
  125. {
  126.     [thePiece newPiece];
  127.     pieceVisible = YES;
  128.     return self;
  129. }
  130.  
  131. /*
  132.  * TetApp will inform us when the game has been stopped.
  133.  */
  134. - end:sender
  135. {
  136.     pieceVisible = NO;
  137.     [self display];
  138.     return self;
  139. }
  140.  
  141. - showNext:sender
  142. {
  143.     showNext = [showNextSwitch state];
  144.     if (pieceVisible)
  145.       [self display];
  146.     return self;
  147. }
  148.  
  149.  
  150. - free
  151. {
  152.     [thePiece free];
  153.     return [super free];
  154. }
  155.  
  156. @@end
  157. @
  158.  
  159.  
  160. 1.7
  161. log
  162. @*** empty log message ***
  163. @
  164. text
  165. @d26 1
  166. a26 1
  167.  
  168. a29 1
  169.     pieceVisible = showNext = NO;
  170. d36 1
  171. d84 1
  172. a84 1
  173.     showNext = [sender state];
  174. @
  175.  
  176.  
  177. 1.6
  178. log
  179. @*** empty log message ***
  180. @
  181. text
  182. @a47 6
  183. - start:sender
  184. {
  185.     [thePiece newPiece];
  186.     pieceVisible = YES;
  187.     return self;
  188. }
  189. d62 13
  190. d77 3
  191. a79 3
  192.     pieceVisible = NO;
  193.     [self display];
  194.     return self;
  195. @
  196.  
  197.  
  198. 1.5
  199. log
  200. @*** empty log message ***
  201. @
  202. text
  203. @d20 4
  204. a23 1
  205.     [[NXImage findImageNamed:"Block1"] getSize:&size];
  206. a29 3
  207.     thePiece = [[Piece alloc] init];
  208.     [thePiece newPiece];
  209.  
  210. d31 3
  211. d40 5
  212. a44 3
  213.  
  214.     if (pieceVisible && showNext)
  215.         [thePiece draw:self];      // Show the next piece
  216. d62 1
  217. a62 1
  218.     [thePiece newPiece];
  219. @
  220.  
  221.  
  222. 1.4
  223. log
  224. @*** empty log message ***
  225. @
  226. text
  227. @d16 1
  228. @
  229.  
  230.  
  231. 1.3
  232. log
  233. @*** empty log message ***
  234. @
  235. text
  236. @d20 1
  237. a57 3
  238. #ifdef DEBUG
  239.      [[NXApp getCheater] setPiece:thePiece];
  240. #endif
  241. a76 8
  242. /*
  243.  *  Tell the piece to call the cheater to determine the next block to drop.
  244.  */
  245. - setCheating:sender
  246. {
  247.     [thePiece setCheating:[sender intValue]];
  248.     return self;
  249. }
  250. @
  251.  
  252.  
  253. 1.2
  254. log
  255. @Tetris 1.2
  256. @
  257. text
  258. @d5 1
  259. d18 1
  260. d20 2
  261. a21 1
  262.     [self setElementSize:&size];
  263. d23 1
  264. a23 1
  265.     [self setIntercell:&size];
  266. d37 1
  267. a37 1
  268.         [thePiece draw:self];
  269. d51 3
  270. d56 4
  271. d73 13
  272. a85 4
  273.     showNext = [sender state];
  274.     if (pieceVisible)
  275.         [self display];
  276.     return self;
  277. @
  278.  
  279.  
  280. 1.1
  281. log
  282. @Initial revision
  283. @
  284. text
  285. @d1 4
  286. a4 1
  287.  
  288. d15 1
  289. a15 1
  290.     
  291. d21 1
  292. d24 1
  293. d32 1
  294. @
  295.